#include <bits/stdc++.h>

using namespace std;

#define N 100000

namespace Bit
{ // binary index tree，二叉索引树，还有一个名字叫做 Fenwick's Tree ，由发明者命名
    int n;
    int s[N] = {0, 0};
    int lowbit(int p) { return p & (-p); }
    void modify(int p, int v)
    {
        for (; p <= n; p += lowbit(p))
            s[p] += v;
    }
    int query(int p)
    {
        int ret = 0;
        for (; p > 0; p -= lowbit(p))
            ret += s[p];
        return ret;
    }
    int query(int l, int r) { return query(r) - query(l - 1); }
}

class NumArray
{
    int n;
    vector<int> mnums;

public:
    NumArray(vector<int> &nums)
    {
        n = Bit::n = nums.size();
        fill(begin(Bit::s), end(Bit::s), 0); // 显式初始化 Bit::s 数组为 0
        for (int i = 1; i <= n; ++i)
        {
            int num = nums[i - 1];
            cout << Bit::s[i] << " ";
            cout << num << " ";
            Bit::s[i] += num;
            cout << Bit::s[i] << " ";
            int nxt = i + (i & (-i));
            if (nxt <= n)
            {
                Bit::s[nxt] += Bit::s[i];
            }
        }
        mnums = nums;
    }

    void update(int index, int val)
    {
        Bit::modify(index + 1, val - mnums[index]);
        mnums[index] = val;
    }
    int sumRange(int left, int right)
    {
        return Bit::query(left + 1, right + 1);
    }
};